<?php
/**
 * Created by PhpStorm.
 * User: Dick
 * Date: 2016/4/13
 * Time: 15:53
 */

namespace Controller;

use Model\Response;
use Method\PageData;

class Repeat
{

    public function sendrepeat()
    {
        $response = new Response();
        $response->who = $_SESSION['user']->id;
        $response->content = $_POST['content'];
        $response->tocomment = $_POST['tocomment'];
        $response->towho = $_POST['towho'];
        $response->datetime = date("Y-m-d H:i:s");
        $response->SendResponse();
    }

    public function getrepeat()
    {
        $repeatid = $_POST['id'];
        $obj = 'WHERE tocomment = ' . $repeatid;
        $pagedata = new PageData('response', $obj);
        $pagedata->execute();
        $page = $pagedata->getContext();
        Response::GetResponse($repeatid, $page);
    }

    public function getnotifications()
    {
//        $userid = 5;
        $userid = $_SESSION['user']->id;
        $obj = 'LEFT JOIN mood ON response.tocomment= mood.id WHERE (response.towho = ' . $userid . ' || mood.from= ' . $userid . ') && response.who!= ' . $userid;
        $pagedata = new PageData('response', $obj);
        $pagedata->setRecordPrePage(40);
        $pagedata->execute();
        $page = $pagedata->getContext();
        Response::GetAllResponse($userid, $page);
    }

    public function getwhorepeat()
    {
        $towho = $_POST['towho'];
        Response::GetWhoResponse($towho);
    }
}